package com.hnucm.eatwhat_java.dao;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.hnucm.eatwhat_java.pojo.Shop;

@Database(entities = {Shop.class},version = 1,exportSchema = false)
public abstract class ShopDaoDataBase extends RoomDatabase {
    public abstract ShopDao getShopDao();

    //单例类
    private static volatile ShopDaoDataBase INSTANCE;

    public static ShopDaoDataBase getInstance(final Context context){
        if(INSTANCE==null){
            synchronized (ShopDaoDataBase.class){
                if (INSTANCE==null){
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                        ShopDaoDataBase.class,"shop")
                        .allowMainThreadQueries()
                        .build();
                }
            }
        }
        return INSTANCE;
    }
}
